/*
 *  Copyright 2011 Alexey Andreev.
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package org.xthl.core;

import org.nop.core.ControllerServices;
import org.nop.templating.Template;
import org.nop.util.Injected;

/**
 *
 * @author Alexey Andreev
 */
public abstract class AbstractFragment implements FragmentRenderer {
    protected ControllerServices services;

    @Injected
    public void setServices(ControllerServices services) {
        this.services = services;
    }

    protected <T extends Template> T createView(Class<T> templateType) {
        return services.createTemplate(templateType);
    }

    protected <T> T obtainForm(Class<T> formType, String prefix) {
        return services.receiveForm(formType, prefix);
    }

    protected <T> T bundle(Class<T> bundleType) {
        return services.getBundle(bundleType);
    }

    protected <T> T route(Class<T> type) {
        return services.getRoute(type);
    }
}
